﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using System.Web.UI;
//using System.Web.UI.WebControls;
//using Touch2Like.DAL;
//using System.Data;
//using Touch2Like.Model;

//namespace Touch2Like.Web.Customer
//{
//    public partial class Profile : System.Web.UI.Page
//    {
//        protected void Page_Load(object sender, EventArgs e)
//        {
//            if (WebUtility.UserGUID == "0")
//            {
//                Response.Redirect("/Customer/signin.aspx?next=" + Server.UrlEncode("/Customer/Profile.aspx"));
//            }

//            this.Master.CurrentPage = "NFCTagManager";

//            if (!IsPostBack)
//            {
//                Touch2Like.DAL.UserDAL user = new Touch2Like.DAL.UserDAL();
//                UserInfo userInfo = user.GetUserByUserGuid(WebUtility.UserGUID);

//                if (userInfo != null)
//                {
//                    lb_UserInfo.Text = "<div>User name: " + userInfo.UserName + "</div>" + "<div>Email: " + userInfo.Email + "</div>" + "<div>Phone: " + userInfo.Phone + "</div>";
//                }

//                CommonAddress address = new CommonAddress();
//                GridView_Address.DataSource = address.GetByUserID(WebUtility.UserGUID);
//                GridView_Address.DataBind();
//            }
//        }

//        protected void GridView_Address_PageIndexChanging(object sender, GridViewPageEventArgs e)
//        {
//            GridView_Address.PageIndex = e.NewPageIndex;
//            CommonAddress address = new CommonAddress();
//            GridView_Address.DataSource = address.GetByUserID(WebUtility.UserGUID);
//            GridView_Address.DataBind();
//        }

//        protected void GridView_Address_Sorting(object sender, GridViewSortEventArgs e)
//        {
//            if (Session["SortDirection"] == null) Session["SortDirection"] = "ASC";
//            if (Session["SortBy"] == null) Session["SortBy"] = "ListID";
//            if (e.SortExpression == Session["SortBy"].ToString()) Session["SortDirection"] = Session["SortDirection"] == "ASC" ? "DESC" : "ASC";
//            else Session["SortDirection"] = "ASC";

//            CommonAddress address = new CommonAddress();
//            DataTable dt = address.GetByUserID(WebUtility.UserGUID);
//            DataView dv = new DataView(dt);
//            Session["SortBy"] = e.SortExpression;
//            dv.Sort = GetSortBy();
//            GridView_Address.DataSource = dv;
//            GridView_Address.DataBind();
//        }

//        string GetSortBy()
//        {
//            string sortby = "";

//            sortby = " ListID";

//            if (Session["SortBy"] != null)
//            {
//                if (!string.IsNullOrEmpty(Session["SortBy"].ToString()))
//                {
//                    sortby = " " + Session["SortBy"].ToString();
//                }
//            }
//            else Session["SortBy"] = sortby;

//            if (Session["SortDirection"] != null)
//            {
//                if (!string.IsNullOrEmpty(Session["SortDirection"].ToString()))
//                {
//                    return sortby + " " + Session["SortDirection"].ToString();
//                }
//            }

//            return sortby + " " + "ASC";
//        }

//        protected void btn_Delete_Click(object sender, EventArgs e)
//        {
//            CommonAddress address = new CommonAddress();
//            foreach (GridViewRow row in GridView_Address.Rows)
//            {
//                CheckBox cb_ListID = row.FindControl("cb_ListID") as CheckBox;
//                if (cb_ListID != null && cb_ListID.Checked)
//                {
//                    HiddenField tb_ListID = row.FindControl("tb_ListID") as HiddenField;
//                    if (tb_ListID != null)
//                    {
//                        if (tb_ListID.Value.Trim() != "")
//                            address.Delete(Convert.ToInt32(tb_ListID.Value.Trim()));
//                    }
//                }
//            }

//            DataTable dt = address.GetByUserID(WebUtility.UserGUID);
//            DataView dv = new DataView(dt);
//            dv.Sort = GetSortBy();
//            GridView_Address.DataSource = dv;
//            GridView_Address.DataBind();
//        }
//    }
//}